package model;

import com.googlecode.objectify.NotFoundException;
import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.util.DAOBase;

public class UserDAO extends DAOBase {
	
	
	static {
		ObjectifyService.register(User.class);
	}
	
	
	//Singleton
	private static UserDAO daoInstance;
	public static UserDAO get() {
		if (daoInstance == null) daoInstance = new UserDAO();
		return daoInstance;
	}
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	public void putUser(User user) {
		ofy().put( user );	
	}
	
	public User getUser(Long userId) {
		try {
			return ofy().get(User.class,userId);
		} catch(NotFoundException e) {
			return null;
		} 
	}
	

}